package com.enfi.api.modules.db.entity;

import lombok.*;
import org.hibernate.annotations.*;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
import java.util.List;


/**
 * 预警內容建议(WarningSuggestion)实体类
 *
 * @author wind
 * @since 2020-04-07 15:56:42
 */
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name="t_tbl_warning_suggestion")
@EntityListeners(AuditingEntityListener.class)
@DynamicInsert
@DynamicUpdate
public class WarningSuggestion implements Serializable {

    private static final long serialVersionUID = 1L;

    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;

    /**
     * 预警ID
     */    
    private Integer warningId;

    /**
     * 用户ID
     */    
    private String userId;

    /**
     * 用户名称
     */    
    private String userName;

    /**
     * 建议
     */    
    private String content;

    /**
     * 查看状态
     */    
    private Integer status;

    @CreatedDate
    private Date createTime;

    @LastModifiedDate
    private Date updateTime;

    @NotFound(action = NotFoundAction.IGNORE)
    @OneToMany(fetch = FetchType.LAZY,targetEntity = WarningFeedback.class,cascade = {CascadeType.ALL})
    @Fetch(value = FetchMode.JOIN)
    @JoinColumn(name = "suggestionId")
    private List<WarningFeedback> feedbacks;
}